package clienteremotoclásico;

import ejb.CalculadoraConEstadoRemote;
import ejb.CalculadoraRemote;
import java.util.Properties;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;

public class ClienteSessionConEstado2 {

    public static void main(String[] args) throws NamingException, InterruptedException {
        Properties props = new Properties();
        props.setProperty("java.naming.factory.initial",
                "com.sun.enterprise.naming.SerialInitContextFactory");
        props.setProperty("java.naming.factory.url.pkgs",
                "com.sun.enterprise.naming");
        props.setProperty("java.naming.factory.state",
                "com.sun.corba.ee.impl.presentation.rmi.JNDIStateFactoryImpl");
        // optional.  Defaults to localhost.  Only needed if web server is running
        // on a different host than the appserver   
        props.setProperty("org.omg.CORBA.ORBInitialHost", "localhost");
        // optional.  Defaults to 3700.  Only needed if target orb port is not 3700.
        props.setProperty("org.omg.CORBA.ORBInitialPort", "3700");
        
        Context ctx = new InitialContext(props);
        CalculadoraConEstadoRemote calc = (CalculadoraConEstadoRemote) ctx.lookup("java:global/ProyectoJ2EE/ProyectoJ2EE-ejb/CalculadoraConEstado!ejb.CalculadoraConEstadoRemote");
        calc.setOp1(5);
        calc.setOp2(3);
        Thread.sleep(60000);
        double res = calc.suma();
        System.out.println(res);
    }
}
